# coding: utf8
#########################################################################
# Aria Default Setting
#########################################################################
# Location                    : models/init_auto_user.py
# Corresponding controller    : none at this time
#
# Organization                : TBD
# Author                      : Christopher Steel
# Copyright                   : 2010
# Contributors                :
# Last Changes                : 2010-02-25
#
# Description :
#
# This model automatically creates a user in auth_user that is used as
# the user_id for automated menu database entries.
#
# if the automatic user id is not found one is created using the 
# variables fname and lname that can be set below.
#
# if a user id or user id's are found that refer to record or records
# that have a first name that is the same as the fname variable below
# then the first user id corresponding to the fname variable is set
# as the global variable automated_user_id
#
#
######################
# auth_user variables
######################
#
# Change variables if you like to reflect your installation preferences
#
fname='automated'
lname='initializer'
#
##############################
# db.auth_user insertion code
##############################
#
#   auth_user.first_name
#   auth_user.last_name
fnames_found='None'
rows=db(db.auth_user.first_name == fname).select(db.auth_user.ALL)
for row in rows:
    fnames_found = row.first_name
if fnames_found == 'None':
    automated_user_id = db.auth_user.insert(first_name=fname,last_name=lname)
else:
    automated_user_id = fnames_found[0]
